package com.briup.estore.web.servlet;

import com.briup.estore.common.result.Result;
import com.briup.estore.common.dto.OrderPaySuccessDTO;
import com.briup.estore.common.utils.JsonUtils;
import com.briup.estore.service.OrderService;
import com.briup.estore.service.impl.OrderServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author briup-adam
 * @Date 2023/8/4 下午3:26
 * @Description 支付成功后修改订单状态
 **/
@WebServlet("/order/paySuccess")
public class OrderPaySuccessServlet extends  BaseServlet {
    private OrderService orderService=new OrderServiceImpl();

    @Override
    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        OrderPaySuccessDTO dto = JsonUtils.toObject(readData(req), OrderPaySuccessDTO.class);
        orderService.paySuccess(dto);
        writeData(resp, Result.success());
    }
}
